// https://nuxt.com/docs/api/configuration/nuxt-config
// @ts-ignore
import { defineNuxtModule } from 'nuxt'

// 处理process.env以便在客户端能够取到
let define: any = {};
Object.keys(process.env).forEach((name: string) => {
  if (name.startsWith('XS_')) {
    define["process.env." + name] = JSON.stringify(process.env[name]);
  }
});
console.log(define)

// 调用户后端本地接口走代理
let server = {}
if (process.env.XS_LOCAL_URL) {
  server = {
    proxy: {
      '/webapi': {
        target: process.env.XS_OPEN_PROXY_PATH,
        changeOrigin: true,
        prependPath: true,
        rewrite: (path: string) => path.replace(/^\/webapi/, ''),
      },
    },
  }
}

export default defineNuxtConfig({
  modules: [
    'nuxt-swiper',
    '@element-plus/nuxt',
    'nuxt-aos',
    '@pinia/nuxt',
    '@pinia-plugin-persistedstate/nuxt'
  ],
  router: {
    options: {
      
    }
  },
  app: {
    head: {
      meta: [
        { charset: 'utf-8' },
        { name: 'viewport', content: 'width=device-width, initial-scale=1' },
        { hid: 'viewport', name: 'viewport', content: "width=1350,  user-scalable=no,viewport-fit=cover" },
        { hid: 'description', name: 'description', content: '甬易付APP是易智付科技有限公司(简称“首信易支付”)旗下为广大用户倾力打造的综合性移动支付钱包,甬易付主要功能以POS收款、银联云闪付、二维码支付、NFC、扫脸支付等致力于为用户提供综合支付场景平台。 易智付科技(北京)有限公司是国内首家第三方支付品牌。首信易支付PayEase创始于1998年，是国内首家第三方支付品牌，于2011年获得人民银行颁发的第三方支付业务许可。' },
        { hid: 'keywords', name: 'keywords', content: '甬易，甬易付app，甬易付app下载，甬易付，甬易支付，海科，海科融通，海科支付，甬易官网，甬易付官网，支付，快捷付' },
        { name: 'format-detection', content: 'telephone=no' }
      ],
    },
  },
  css: [
    '~/assets/scss/reset.scss',
    '~/assets/scss/common.scss',
    '~/assets/css/animate.min.css',
    'element-plus/dist/index.css'
  ],
  compatibilityDate: '2024-04-03',
  devtools: { enabled: true },
  devServer: {
    port: 8303
  },
  vite: {
    server,
    define: {
      ...define
    },
    css: {
      preprocessorOptions: {
        scss: {
          additionalData: `@use "@/assets/scss/variables.scss" as element;`,
        },
      },
    },
  },
  elementPlus: {
    importStyle: 'scss',
  },
  build: {
    analyze: {
      analyzerMode: 'static',
    }
  },
  nitro: {
    compressPublicAssets: {
      gzip: true,
      brotli: true,
    },
  },
  generate: {
    routes: [
      // '/',
      '/product_ability',
      '/solution/catering',
      '/solution/retail',
      '/solution/payment',
    ]
  }
})